import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
// @ts-ignore
import pkg from './package.json'

export default defineConfig({
  css: {
    preprocessorOptions: {
      less: {
        javascriptEnabled: true,
      },
    },
  },
  plugins: [
    vue({
      script: {
        // @ts-ignore
        defineModel: true,
      },
    }),
    vueJsx()],
  build: {
    lib: {
      entry: 'src/index.ts',
      name: 'dmy',
      fileName: format => `index.${format}.js`,
    },
    emptyOutDir: true,
    rollupOptions: {
      external: ['vue', 'vue-router', 'axios', 'dayjs'],
      output: {
        globals: {
          'vue-router': 'VueRouter',
          vue: 'Vue',
          dayjs: 'dayjs',
          axios: 'axios'
        },
      },
    },
  },
})
